/****************************************************************************
*                                                                           *
* settings.cpp									                            *
*                                                                           *
* ALaRI 2008												                *
*                                                                           *
****************************************************************************/ 

/****************************************************************************
* Includes                                                                  *
****************************************************************************/ 
#include "settings.h"

#include <QDialogButtonBox>
#include <QTabWidget>
#include <QLayout>

CSettingsDialog::CSettingsDialog(CSimProperty *pQObjAppProp,  QWidget *pParent)
	: QDialog(pParent), m_pAppProp(pQObjAppProp)
{
	Q_ASSERT(m_pAppProp != NULL);	

	m_pQTabWidget = new QTabWidget();
	m_pSimulationTab = new CSimulationTab(pQObjAppProp);
	m_pSensorTab = new CSensorTab(pQObjAppProp);

	m_pQTabWidget->addTab(m_pSimulationTab, tr("Simulation"));
	m_pQTabWidget->addTab(m_pSensorTab, tr("Sensors"));

	m_pQDialogButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok
								  | QDialogButtonBox::Cancel);

	connect(m_pQDialogButtonBox, SIGNAL(accepted()), SLOT(accept()));
	connect(m_pQDialogButtonBox, SIGNAL(rejected()), SLOT(reject()));

	QVBoxLayout *pQVBoxLayoutMain = new QVBoxLayout;
	pQVBoxLayoutMain->addWidget(m_pQTabWidget);
	pQVBoxLayoutMain->addWidget(m_pQDialogButtonBox);
	setLayout(pQVBoxLayoutMain);

	setWindowTitle(tr("Application Settings..."));
}

void CSettingsDialog::accept()
{
	Q_ASSERT(NULL != m_pAppProp);
	m_pAppProp->setFrequency(m_pSimulationTab->frequency());
	m_pAppProp->setResolution(m_pSimulationTab->resolution());
	m_pAppProp->setOutputPower(m_pSensorTab->outputPower());
	m_pAppProp->setSensitivity(m_pSensorTab->sensitivity());
	done(QDialog::Accepted);
}

void CSettingsDialog::reject()
{
	done(QDialog::Rejected);
}
/****************************************************************************
/* End of file																*
****************************************************************************/
